package com.lin.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lin.blog.entity.Permission;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lin
 * @since 2020-03-08
 */
public interface PermissionMapper extends BaseMapper<Permission> {

    /**
     * 通过角色名获取权限
     * @param roleName
     * @return
     */
    @Select("select *from permission where permission_id in(\n" +
            "select rp.permission_id from role r,role_permission rp where r.role_id = rp.role_id and r.name = #{roleName}\n" +
            ")")
    public List<Permission> getPermissionByRoleName(String roleName);
}
